package com.approval.approvalapp.util;

import com.alibaba.fastjson.JSONObject;
import com.approval.approvalapp.MyAppliaction;
import com.approval.approvalapp.bean.ErrorBean;

/**
 * Created by louyulin on 2019/4/28.
 * 错误类解析工具类
 */

public class ErrorBeanUtil {
    public static ErrorBeanUtil instance;

    public static ErrorBeanUtil getInstance() {
        if (instance == null) {
            instance = new ErrorBeanUtil();
        }
        return instance;
    }

    private ErrorBeanUtil() {

    }
    public static void getErrorMessage(String errorJSON) {
        try {
            ErrorBean errorBean = JSONObject.parseObject(errorJSON, ErrorBean.class);
            ToastUtil.showToast(MyAppliaction.getInstance(), errorBean.getError_message());
        } catch (Exception e) {
            ToastUtil.showToast(MyAppliaction.getInstance(), "当前网络不可用,请检查网络连接");
        }
    }
}
